package com.ruoyi.rms.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.rms.utils.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.rms.mapper.MemberRechargeMapper;
import com.ruoyi.rms.domain.MemberRecharge;
import com.ruoyi.rms.service.IMemberRechargeService;

/**
 * 会员充值信息Service业务层处理
 * 
 * @author wyl
 * @date 2024-03-12
 */
@Service
public class MemberRechargeServiceImpl implements IMemberRechargeService 
{
    @Autowired
    private MemberRechargeMapper memberRechargeMapper;

    /**
     * 查询会员充值信息
     * 
     * @param rechargeId 会员充值信息主键
     * @return 会员充值信息
     */
    @Override
    public MemberRecharge selectMemberRechargeByRechargeId(Long rechargeId)
    {
        return memberRechargeMapper.selectMemberRechargeByRechargeId(rechargeId);
    }

    /**
     * 查询会员充值信息列表
     * 
     * @param memberRecharge 会员充值信息
     * @return 会员充值信息
     */
    @Override
    public List<MemberRecharge> selectMemberRechargeList(MemberRecharge memberRecharge)
    {
        return memberRechargeMapper.selectMemberRechargeList(memberRecharge);
    }

    /**
     * 新增会员充值信息
     * 
     * @param memberRecharge 会员充值信息
     * @return 结果
     */
    @Override
    public int insertMemberRecharge(MemberRecharge memberRecharge)
    {
        memberRecharge.setRechargeId(IdUtils.createId());
        memberRecharge.setCreateTime(DateUtils.getNowDate());
        if (memberRecharge.getWxId() == null) {
            // 如果微信号为空，代表这是由管理端发出的操作，设置操作人
            memberRecharge.setCreateBy(SecurityUtils.getUsername());
        }
        return memberRechargeMapper.insertMemberRecharge(memberRecharge);
    }

    /**
     * 修改会员充值信息
     * 
     * @param memberRecharge 会员充值信息
     * @return 结果
     */
    @Override
    public int updateMemberRecharge(MemberRecharge memberRecharge)
    {
        return memberRechargeMapper.updateMemberRecharge(memberRecharge);
    }

    /**
     * 批量删除会员充值信息
     * 
     * @param rechargeIds 需要删除的会员充值信息主键
     * @return 结果
     */
    @Override
    public int deleteMemberRechargeByRechargeIds(Long[] rechargeIds)
    {
        return memberRechargeMapper.deleteMemberRechargeByRechargeIds(rechargeIds);
    }

    /**
     * 删除会员充值信息信息
     * 
     * @param rechargeId 会员充值信息主键
     * @return 结果
     */
    @Override
    public int deleteMemberRechargeByRechargeId(Long rechargeId)
    {
        return memberRechargeMapper.deleteMemberRechargeByRechargeId(rechargeId);
    }
}
